
public class Stack_ImplArray implements Stack {
	private final int max = 20;
	private int stackPointer = 0;
	private Element[] liste = new Element[max];
	
	public boolean push(Element obj) {
		try {
			liste[stackPointer] = obj;
			stackPointer++;
			return true;
		} catch(ArrayIndexOutOfBoundsException e) {
			Element[] tempListe = new Element[liste.length + 10];
			for(int i = 0; i <= liste.length; i++) {
				tempListe[i] = liste[i];
			}
			liste = tempListe;
			push(obj);
		}
		return false;
	}

	public Element pop() {
		if(stackPointer > 0) {
			stackPointer--;
			Element el = liste[stackPointer];
			return el;
		} else {
			return null;
		}
	}

	public Element top() {
		if(stackPointer > 0) {
			try{
				return liste[stackPointer -1];
			} catch(NullPointerException e) {
				return null;
			}
		}
		return null;
		
	}

	public boolean empty() {
		if(stackPointer == 0)
			return true;
		return false;
	}

}
